<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
	prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
	prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
	prefix="logic"%>
<html>
<head>
<title>A Free Online Rental Application</title>
<script LANGUAGE="JavaScript">
	function validateSearchForm() {
		if (document.optSearchForm.searchKey.value == "") {
			alert("Search Key Word should n't be left blank");
			document.optSearchForm.searchKey.focus();
			return false;
		} else {
			document.optSearchForm.action = "optSearch.do?dispatch=getHomes";
			document.optSearchForm.submit();
		}
	}
	function next(){
		document.optSearchForm.action = "optSearch.do?dispatch=getHomes&nav=more";
		document.optSearchForm.submit();
	}
	function prev(){
		document.optSearchForm.action = "optSearch.do?dispatch=getHomes&nav=less";
		document.optSearchForm.submit();
	}
		
</script>
</head>
<body>
<table width="100%">
	<tr>
		<td align="center" align="left">
		<h4><bean:message key="rental.m1" /></h4>
		</td>
		<td align="center"><a href="home.do?dispatch=addProperty"><bean:message
			key="rental.addYourProperty" /> </a></td>
		<td align="center"><a href="signout.do?dispatch=signout"><bean:message
			key="rental.signout" /> </a></td>
	</tr>
</table>
<CENTER>
<h1><bean:message key="rental.m2" /></h1>
<html:errors />
<table width="100%">
	<html:form action="optSearch">
		<tr>
			<td><bean:message key="property.state" />/ <bean:message
				key="property.city" />/ <bean:message key="property.localtion" />/
			<bean:message key="property.zipCode" />/ <bean:message
				key="property.rentRange" />&nbsp; <logic:present name="searchForm">
				<html:text name="searchForm" property="searchKey" />
			</logic:present> <logic:notPresent name="searchForm">
				<html:text property="searchKey" />
			</logic:notPresent><input type="button" value="Search Now!"
				onclick="validateSearchForm()" /></td>
		</tr>
	</html:form>
</table>

<table width="100%" height="10">
	<tr>
		<td></td>
	</tr>
</table>
<table width="100%">
    <tr>
      <td align="right"><logic:present name="backward"><input type="button"
							value="<< Previous " onclick="prev()" /></logic:present></td>
      <td align="left"><logic:present name="forward"><input type="button"
						value="Next >>" onclick="next()" /></logic:present></td>
    </tr>
	<tr>
		<td width="90%">
		<table BORDER=5 width="90%">
			<logic:present name="homes">
				<TR>
					<td><B><bean:message key="property.name" /> </B> &nbsp;</td>
					<td><B><bean:message key="property.rent" /> </B>&nbsp;</td>
					<td><B><bean:message key="property.maintenanceCost" /> </B>&nbsp;</td>
					<td><B><bean:message key="property.rentNegotiable" /> </B>&nbsp;</td>
					<td><B><bean:message key="property.zipCode" /> </B> - &nbsp;</td>
					<td><B><bean:message key="property.cityName" /> </B>&nbsp;</td>
					<td width="200"><B><bean:message key="property.message" />
					</B>&nbsp;</td>
				</TR>
				<logic:iterate id="home" name="homes">
					<TR>
						<td></td>
					</TR>
					<TR>
						<td><A href="show.do?p=<bean:write name="home" property="id"/>"><bean:write name="home" property="name" /></A></td>
						<td><bean:write name="home" property="rent" /></td>
						<td><bean:write name="home" property="maintenanceCost" /></td>
						<td><bean:write name="home" property="rentNegotiable" /></td>
						<td><bean:write name="home" property="zipCode" /></td>
						<td><bean:write name="home" property="cityName" /></td>
						<td width="200"><bean:write name="home" property="message" /></td>
					</TR>
					<TR>
						<td></td>
					</TR>
				</logic:iterate>
			</logic:present>
		</table>
		</td>
		<td></td>
	</tr>
</table>
</CENTER>
</body>
</html>
